import request from '@/utils/request'

// 获取问诊列表
export function getConsultationList(params) {
  return request({
    url: '/api/doctor/consultations',
    method: 'get',
    params: {
      current: params.current,
      size: params.size,
      status: params.status
    }
  })
}

// 接受问诊
export function acceptConsultation(id) {
  return request({
    url: `/api/doctor/consultations/${id}/accept`,
    method: 'put'
  })
}

// 拒绝问诊
export function rejectConsultation(id) {
  return request({
    url: `/api/doctor/consultations/${id}/reject`,
    method: 'put'
  })
}

// 结束问诊
export function endConsultation(id, diagnosis) {
  return request({
    url: `/api/doctor/consultations/${id}/end`,
    method: 'put',
    data: { diagnosis }
  })
}

// 获取问诊详情
export function getConsultationDetail(id) {
  return request({
    url: `/api/consultations/detail/${id}`,
    method: 'get'
  })
}

// 获取聊天记录
export function getChatMessages(consultationId) {
  return request({
    url: `/api/consultations/${consultationId}/messages`,
    method: 'get'
  })
}

// 发送消息
export function sendMessage(consultationId, data) {
  return request({
    url: `/api/consultations/${consultationId}/message`,
    method: 'post',
    data: {
      content: data.content,
      type: data.type || 'text'
    }
  })
}


// 获取用户问诊记录
export function getUserConsultations(params) {
  return request({
    url: '/api/consultations/user',
    method: 'get',
    params
  })
}
